//
//  UIBarButtonItem+Extension.swift
//  微博
//
//  Created by 朱万龙 on 2016/12/11.
//  Copyright © 2016年 zwl. All rights reserved.
//

import UIKit
extension UIBarButtonItem{

    convenience init(title:String,fontSize: CGFloat = 16,target: AnyObject,action:Selector,isBack:Bool = false){
        let btn = UIButton()
        btn.setTitle(title, for: .normal)
        btn.setTitleColor(UIColor.darkGray, for: .normal)
        btn.setTitleColor(UIColor.orange, for: .highlighted)
        if isBack {
            let imageName = "navigationbar_back_withtext"
            btn.setImage(UIImage(named:imageName), for: .normal)
            btn.setImage(UIImage(named:imageName + "_highlighted"), for: .highlighted)
        }
        btn.addTarget(target, action: action, for: .touchUpInside)
        btn.titleLabel?.font = UIFont.systemFont(ofSize: fontSize)
        btn.sizeToFit()
        self.init(customView:btn)
    }
}
